class Ball extends Spirit {
  constructor() {
    super('img/ball.png')
    this.speedX = 3
    this.speedY = 3
    this.x = 250
    this.y = 330
    this.fired = false
  }
  move() {

    if (!this.fired) {
      return
    }

    if (this.x + this.w > 600 || this.x < 0) {
      this.speedX *= -1
    }
    if (this.y < 0) {
      this.speedY *= -1
    }

    this.x += this.speedX
    this.y += this.speedY
  }
  // y方向反弹
  bounce() {
    this.speedY *= -1
  }

  fire() {
    this.fired = true
  }

  update() {
    this.move()
  }

}